package com.guigu.qingcheng.orderservice.controller;


import com.guigu.qingcheng.orderservice.service.TbOrderConfigService;
import com.guigu.qingcheng.pojo.order.TbOrderConfig;
import com.guigu.qingcheng.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author testjava
 * @since 2020-07-08
 */
@RestController
@RequestMapping("orderconfig")
public class TbOrderConfigController {
    @Autowired
    private TbOrderConfigService tbOrderConfigService;

    @GetMapping("findById")
    public R findById (Integer id) {
        TbOrderConfig tbOrderConfig = tbOrderConfigService.getById(id);
        if (tbOrderConfig  == null)
            return R.error();
        return R.ok().data("tbOrderConfig",tbOrderConfig);
    }

    //新增
    @PostMapping("add")
    public R add (@RequestBody TbOrderConfig tbOrderConfig) {
        boolean save = tbOrderConfigService.save(tbOrderConfig);
        if (save)
            return R.ok();
        return R.error();
    }

    //修改
    @PostMapping("update")
    public R update (@RequestBody TbOrderConfig tbOrderConfig) {
        boolean save = tbOrderConfigService.updateById(tbOrderConfig);
        if (save)
            return R.ok();
        return R.error();
    }

}

